﻿using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using GurLoader.ViewModel;

namespace GurLoader.View
{
    [ExcludeFromCodeCoverage]
    public class DefaultViewBuilder : IViewBuilder
    {
        public IWindow CreateMainWindow(GurLoaderViewModel vm, bool isVisible)
        {
            var window = new MainWindow();
            window.DataContext = vm;
            window.Show();

            if ( ! isVisible )
                window.Hide();

            return window;
        }

        public IWindow CreateHotkeyWindow(bool isVisible)
        {
            var hotkeyWindow = new HiddenHotkeyWindow();
            hotkeyWindow.Show();

            if (! isVisible)
                hotkeyWindow.Hide();
            
            return hotkeyWindow;
        }

        public IWindow CreateCaptureAreaWindow(CaptureAreaViewModel vm, int top, int left, int width, int height)
        {
            var captureAreaWindow = new CaptureAreaWindow();
            captureAreaWindow.Top = top;
            captureAreaWindow.Left = left;
            captureAreaWindow.Width = width;
            captureAreaWindow.Height = height;

            captureAreaWindow.DataContext = vm;

            vm.RequestClose += (sender, e) => captureAreaWindow.CloseWindow();

            captureAreaWindow.ShowDialog();

            return captureAreaWindow;
        }


        public IWindow CreateLoginWindow(LoginViewModel viewModel)
        {
            var loginWindow = new LoginView();
            loginWindow.DataContext = viewModel;
            return loginWindow;
        }
    }
}
